<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>新增词条管理</title>

    <meta name="keywords" content="">
    <meta name="description" content="">

    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

    <link rel="shortcut icon" href="favicon.ico"> <link href="__STATIC__/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__STATIC__/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/css/style.css?v=4.1.0" rel="stylesheet">
</head>
<body>

<div style="width: 80%;margin: 0 auto;">
    <div class="ibox-title">
        <h5>查看新增词条</h5>
    </div>
    <form class="form-horizontal m-t" id="signupForm" action="{:url('modify')}" method="post" enctype="multipart/form-data">
        <div class="form-group">
            <label class="col-sm-1 control-label">榜单</label>
            <div class="col-sm-2">
                <select class="form-control m-b" name="bid" value="" style="font-size: 12px;">
                    <option value="1">匠人榜</option>
                    <option value="2">品牌榜</option>
                    <option value="3">珍品榜</option>
                </select>
            </div>
        </div>
        <button class="btn btn-primary" id="s1" type="submit" style="display: none;">提交</button>
    </form>
    {foreach $res as $r}
    <!-- 匠人 -->
    {switch name="$r.bangdan_id"}
    {case value="1"}
    <div class="col-sm-12" style="position: relative;">
        <form action="{:url('addjr')}" method="post" enctype="multipart/form-data">
            <input type="text" name="bangdan_id" value="{$r.bangdan_id}" style="display: none;">
        <table class="table table-bordered ">
            <tr>
                <td>匠人</td>
                <td><input type="text" name="name" value="{$r.name}" style="border: none;"></td>
                <td>审核人</td>
                <td style="color: #47f">{notempty name="$r.nickname"}
                        {$r.nickname}
                    {/notempty}
                </td>
            </tr>
            <tr>
                <td>茶类</td>
                <td id="{$r.Id}">
                    <select class="form-control m-b" value="{$r.teacase_id}" name="teacase_id" style="font-size: 12px; margin-bottom:0">
                    {foreach $teacase as $case}
                    <option value="{$case['id']}" {if condition="$r.teacase_id == $case['id']"}selected='selected'{/if}>{$case['teaname']}</option>
                    {/foreach}
                    </select>
                </td>
                <td>产区</td>
                <td class="area">
                    <select class="form-control m-b" name="teaarea_id" value="{$r.teaarea_id}" style="font-size: 12px; margin-bottom:0">
                        {foreach $r['area'] as $ra}
                        <option value="{$r.teaarea_id}" {if condition="$ra.aid == $r.teaarea_id"}selected='selected'{/if}>{$ra.aname}</option>
                        {/foreach}
                    </select>
                </td>
            </tr>
            <tr>
                <td>联系人</td>
                <td><input type="text" name="contact" value="{$r.contact}" style="border: none;"></td>
                <td>电话</td>
                <td><input type="text" name="phone" value="{$r.phone}" style="border: none;"></td>
            </tr>
            <tr>
                <td>微信</td>
                <td><input type="text" name="wechat" value="{$r.wechat}" style="border: none;"></td>
                <td>申请时间</td>
                <td>{:date("Y-m-d H:i",$r.addtime)}</td>
            </tr>
            <tr>
                <td>简介</td>
                <td colspan="3"><textarea rows="1" cols="115" name="briefintro" style="border: none;">{$r.briefintro}</textarea></td>
            </tr>
            <tr>
                <td rowspan="3">详细介绍</td>
                <td rowspan="3" colspan="3">
                    <textarea rows="5" cols="115" name="detailintro" style="border: none;">{$r.detailintro}</textarea>
                </td>
            </tr>

            {switch name="$r.mark"}
            {case value="1"}
            <img src="__STATIC__/img/sh-t.png" style="position: absolute;top:-35px;right: -5px;width: 100px">
            {/case}
            {case value="2"}
            <img src="__STATIC__/img/sh-sb.png" style="position: absolute;top:-35px;right: -5px;width: 100px">
            {/case}
            {default /}
            <img src="__STATIC__/img/sh-f.png" style="position: absolute;top:-35px;right: -5px;width: 100px">
            {/switch}
            <tr></tr>
            <tr></tr>
            <tr style="text-align: center;">
                <td colspan="4">
                {switch name="$r.mark"}
                    {case value="0"}
                        <button onclick="onSuccess('{$r.Id}','{$r.bangdan_id}')">审核成功</button>
                        <button onclick="onFailed('{$r.Id}','{$r.bangdan_id}')">审核失败</button>
                     {/case}
                     {case value="1"}
                     已审核 
                    <button class="btn btn-primary" id="s1" type="submit" >提交入库</button>
                     {/case}
                    {default /} 
                    已审核 
                {/switch}
                </td>
            </tr>
        </table>
        </form>  
    </div>
    {/case}
    <!-- 品牌 -->
    {case value="2"}
    <div class="col-sm-12" style="position: relative;">
        <form action="{:url('addpp')}" method="post" enctype="multipart/form-data">
            <input type="text" name="bangdan_id" value="{$r.bangdan_id}" style="display: none;">
        <table class="table table-bordered ">
            <tr>
                <td>品牌名称</td>
                <td><input type="text" name="name" value="{$r.name}" style="border: none;"></td>
                <td>审核人</td>
                <td style="color: #47f">{notempty name="$r.nickname"}
                        {$r.nickname}
                    {/notempty}
                </td>
            </tr>
            <tr>
                <td>茶类</td>
                <td>
                    <select class="form-control m-b" value="{$r.teacase_id}" name="teacase_id" style="font-size: 12px; margin-bottom:0">
                    {foreach $teacase as $case}
                    <option value="{$case['id']}" {if condition="$r.teacase_id == $case['id']"}selected='selected'{/if}>{$case['teaname']}</option>
                    {/foreach}
                    </select>
                </td>
                <td>产区</td>
                <td class="area">
                    <select class="form-control m-b" name="teaarea_id" value="{$r.teaarea_id}" style="font-size: 12px; margin-bottom:0">
                        {foreach $r['area'] as $ra}
                        <option value="{$r.teaarea_id}" {if condition="$ra.aid == $r.teaarea_id"}selected='selected'{/if}>{$ra.aname}</option>
                        {/foreach}
                    </select>
                </td>
            </tr>
            <tr>
                <td>关键字</td>
                <td><input type="text" name="relatedwords" value="{$r.relatedwords}" style="border: none;"></td>
                <td>品牌销售额</td>
                <td>
                    <input type="text" name="sale" value="800万" style="border: none;">
                </td>
            </tr>
            <tr>
                <td>公司</td>
                <td><input type="text" name="company" value="{$r.company}" style="border: none;"></td>
                <td>公众号</td>
                <td><input type="text" name="pnumber" value="{$r.pnumber}" style="border: none;"></td>
            </tr>
            <tr>
                <td>联系人</td>
                <td><input type="text" name="contact" value="{$r.contact}" style="border: none;"></td>
                <td>联系电话</td>
                <td><input type="text" name="phone" value="{$r.phone}" style="border: none;"></td>
            </tr>
            <tr>
                <td>微信</td>
                <td><input type="text" name="wechat" value="{$r.wechat}" style="border: none;"></td>
                <td>申请时间</td>
                <td>{:date("Y-m-d H:i",$r.addtime)}</td>
            </tr>
            <tr>
                <td rowspan="3">详细介绍</td>
                <td rowspan="3" colspan="3">
                    <textarea rows="5" name="detailintro" cols="115" style="border: none;">{$r.detailintro}</textarea>
                </td>
            </tr>
            {switch name="$r.mark"}
            {case value="1"}
            <img src="__STATIC__/img/sh-t.png" style="position: absolute;top:-35px;right: -5px;width: 100px">
            {/case}
            {case value="2"}
            <img src="__STATIC__/img/sh-sb.png" style="position: absolute;top:-35px;right: -5px;width: 100px">
            {/case}
            {default /}
            <img src="__STATIC__/img/sh-f.png" style="position: absolute;top:-35px;right: -5px;width: 100px">
            {/switch}
            <tr></tr>
            <tr></tr>
            <tr style="text-align: center;">
                <td colspan="4">
                {switch name="$r.mark"}
                {case value="0"}
                    <button onclick="onSuccess('{$r.Id}','{$r.bangdan_id}')">审核成功</button>
                    <button onclick="onFailed('{$r.Id}','{$r.bangdan_id}')">审核失败</button>
                 {/case}
                {case value="1"}
                     已审核 
                    <button class="btn btn-primary" id="s1" type="submit" >提交入库</button>
                {/case}
                {default /} 
                    已审核 
                {/switch}
                </td>
            </tr>
        </table>
        </form>  
    </div>
    {/case}
    <!-- 珍品 -->
    {case value="3"} 
    <div class="col-sm-12" style="position: relative;">
        <form action="{:url('addzp')}" method="post" enctype="multipart/form-data">
            <input type="text" name="bangdan_id" value="{$r.bangdan_id}" style="display: none;">
        <table class="table table-bordered ">
            <tr>
                <td>珍品名称</td>
                <td><input type="text" name="name" value="{$r.name}" style="border: none;"></td>
                <td>审核人</td>
                <td style="color: #47f">{notempty name="$r.nickname"}
                        {$r.nickname}
                    {/notempty}
                </td>
            </tr>
            <tr>
                <td>茶类</td>
                <td>
                    <select class="form-control m-b" value="{$r.teacase_id}" name="teacase_id" style="font-size: 12px; margin-bottom:0">
                    {foreach $teacase as $case}
                    <option value="{$case['id']}" {if condition="$r.teacase_id == $case['id']"}selected='selected'{/if}>{$case['teaname']}</option>
                    {/foreach}
                    </select>
                </td>
                <td>产区</td>
                <td class="area">
                    <select class="form-control m-b" name="teaarea_id" value="{$r.teaarea_id}" style="font-size: 12px; margin-bottom:0">
                        {foreach $r['area'] as $ra}
                        <option value="{$r.teaarea_id}" {if condition="$ra.aid == $r.teaarea_id"}selected='selected'{/if}>{$ra.aname}</option>
                        {/foreach}
                    </select>
                </td>
            </tr>
            <tr>
                <td>出品人</td>
                <td><input type="text" name="producer" value="{$r.producer}" style="border: none;"></td>
                <td>价格（500g）</td>
                <td><input type="text" name="price" value="{$r.price}" style="border: none;"></td>
            </tr>
            <tr>
                <td>联系人</td>
                <td><input type="text" name="contact" value="{$r.contact}" style="border: none;"></td>
                <td>电话</td>
                <td><input type="text" name="phone" value="{$r.phone}" style="border: none;"></td>
            </tr>
            <tr>
                <td>微信</td>
                <td><input type="text" name="wechat" value="{$r.wechat}" style="border: none;"></td>
                <td>申请时间</td>
                <td>{:date("Y-m-d H:i",$r.addtime)}</td>
            </tr>
            <tr>
                <td>特色</td>
                <td colspan="3">
                    <label class="checkbox-inline">
                        <input type="checkbox" name="zs" id="inlineCheckbox1" {if condition="$r.zs == '√'"}checked {/if} value='√'>正山出品</label>
                    <label class="checkbox-inline">
                        <input type="checkbox" name="gs" id="inlineCheckbox1" {if condition="$r.gs == '√'"}checked {/if} value='√'>古树老丛</label>
                    <label class="checkbox-inline">
                        <input type="checkbox" name="ct" id="inlineCheckbox1" {if condition="$r.ct == '√'"}checked {/if} value='√'>传统工艺</label>
                    <label class="checkbox-inline">
                        <input type="checkbox" name="ds" id="inlineCheckbox1" {if condition="$r.ds == '√'"}checked {/if} value='√'>大师手制</label>
                </td>
            </tr>
            <tr>
               <td>其它荣誉:</td> 
               <td colspan="3">
                <label class="checkbox-inline">
                    <input id="firstname" name="orther" class="form-control" type="text" value="{$r.orther}" style="width: 600px;">
                </label>
                </td>
            </tr>
            <tr>
                <td rowspan="3">详细介绍</td>
                <td rowspan="3" colspan="3">
                    <textarea rows="5" name="detailintro" cols="115" style="border: none;">{$r.detailintro}</textarea>
                </td>
            </tr>
            {switch name="$r.mark"}
            {case value="1"}
            <img src="__STATIC__/img/sh-t.png" style="position: absolute;top:-35px;right: -5px;width: 100px">
            {/case}
            {case value="2"}
            <img src="__STATIC__/img/sh-sb.png" style="position: absolute;top:-35px;right: -5px;width: 100px">
            {/case}
            {default /}
            <img src="__STATIC__/img/sh-f.png" style="position: absolute;top:-35px;right: -5px;width: 100px">
            {/switch}
            <tr></tr>
            <tr></tr>
            <tr style="text-align: center;">
                <td colspan="4">
                {switch name="$r.mark"}
                    {case value="0"}
                        <button onclick="onSuccess('{$r.Id}','{$r.bangdan_id}')">审核成功</button>
                        <button onclick="onFailed('{$r.Id}','{$r.bangdan_id}')">审核失败</button>
                     {/case}
                    {{case value="1"}
                     已审核 
                    <button class="btn btn-primary" id="s1" type="submit" >提交入库</button>
                     {/case}
                    {default /} 
                    已审核 
                {/switch}
                </td>
            </tr>
        </table>
        </form>  
    </div>
    {/case}
    {default /}未知

    {/switch}
    {/foreach}
</div>







<!-- 全局js -->
<script src="__STATIC__/js/jquery.min.js?v=2.1.4"></script>
<script src="__STATIC__/js/bootstrap.min.js?v=3.3.6"></script>
<script src="__STATIC__/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="__STATIC__/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>

<!-- 自定义js -->
<script src="__STATIC__/js/hAdmin.js?v=4.1.0"></script>
<script type="text/javascript" src="__STATIC__/js/index.js"></script>

<!-- 第三方插件 -->
<script type="text/javascript">
    $('select[name=bid]').val("{$bid}");
    $("select[name=bid]").change(function(){
        $('#s1').click();
    });
    $('input[name=bangdanid]').val();

    $("select[name=teacase_id]").change(function(){
        var val = $(this).find("option:selected").attr("value");
        var area = $(this).parent().parent().find('.area').find('select[name=teaarea_id]');
        var url="{:url('reTeaAreaJson')}";
        $.post(url, {teacase_id:val},function(data){
            var areas = JSON.parse(data);
            var option="";
            for(index in areas){
                // console.log(areas[index]["area"])
                var a = "<option value="+areas[index]['id']+">"+areas[index]['area']+"</option>"
                option +=a
            }
            // console.log(area);
            area.html("")
            area.html(option)
        })
    })
    function onSuccess(id,bid){
        var url = '{:url("modifysuccess")}';
        var data = {id:id};
        $.post(url,data,function(res){
            if(res==1){
                alert("审核成功");
            }else{
                alert("审核失败，请重新审核");
            }
            window.location.replace('{:url("modify")}?bid='+bid)
        })
    }
    function onFailed(id,bid){
        var url = '{:url("modifyfialed")}';
        var data = {id:id};
        $.post(url,data,function(res){
            if(res==1){
                alert("审核失败");
            }else{
                alert("审核失败，请重新审核");
            }
            window.location.replace('{:url("modify")}?bid='+bid)
        })
    }
</script>

</body>
</html>